<?php
	session_start();
	require_once('../php/funciones.php');
        require_once '../php/clases/Carrito.php';
        require_once '../php/clases/ItemCarrito.php';
        require_once '../php/clases/ItemSCarrito.php';
        require_once '../php/clases/Productos.php';
        require_once '../php/clases/Tools.php';
        require_once '../php/conf/config.php';
        $tienda = _SITE_URL_."/tienda";
        $estaPagina=$_SERVER['PHP_SELF'];
            $id_categoria = $_REQUEST['cat'];
            $id_subcategoria = $_REQUEST['subcat'];
            $product = new Producto($id_categoria, $id_subcategoria);
            $detalle = $product->aDefinition;
            
	    if (isset($_POST['cantidad'])){
                header ('Location: addtocart.php?articulo='.urlencode($detalle['descripcion']) .'_'.$id_categoria .
                                                        '-'.$id_subcategoria.
                                                        '&precio='. ($detalle['precio'] * $_POST['cantidad'] )."&cantidad=".$_POST['cantidad']);
            }
?>

<html>
<head>
		<meta charset="utf-8">
		<title>Resumen</title>
		<link rel="stylesheet" type="text/css" href="../css/estiloPrincipal.css"/>
		<link rel="stylesheet" type="text/css" href="../css/estilo_login.css" />
		<link rel="stylesheet" type="text/css" href="../css/fonts.css" />
                <link rel="stylesheet" type="text/css" href="css/shop.css" />
                <link rel="stylesheet" type="text/css" href="css/confirmarproductos.css" />
		<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro' rel='stylesheet' type='text/css'>
		<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
		<script type="text/javascript" src="../js/form.js"></script>
		<script type="text/javascript" src="../js/login.js"></script>
		<script type="text/javascript" src="../js/funciones.js"></script>
		<script type="text/javascript" src="../js/sonido-hover.js"></script>
                <script type="text/javascript" src="js/cart-efect.js"></script>
		<script type="text/javascript">
		function refresh() {
			window.setTimeout('recarga()',2500);
		}
		function recarga() {
		    location.reload();
		}
		</script>
</head>
	<body>
	
	<div id="contenedor">
		<div id="head" >
                       <div id="contenedorMenu">
				<ul id="menu" class="efectoMenu nav">
					<li>
						<a href="../principal.php">Principal</a>
						<audio style="display: none" id="beep-two0" controls preload="auto">
							<source src="../sonidos/click.mp3" controls></source>
							<source src="../sonidos/click.ogg" controls></source>
							Your browser isn't invited for super fun audio time.
						</audio>
					</li>
					<li>
						<a href="../historia.php">Introducci&oacute;n</a>
						<audio  style="display: none" id="beep-two1" controls preload="auto">
							<source src="../sonidos/click.mp3" controls></source>
							<source src="../sonidos/click.ogg" controls></source>
							Your browser isn't invited for super fun audio time.
						</audio>
					</li>
					<li>
						<a href="#">Proceso</a>
						<audio  style="display: none" id="beep-two2" controls preload="auto">
							<source src="../sonidos/click.mp3" controls></source>
							<source src="../sonidos/click.ogg" controls></source>
							Your browser isn't invited for super fun audio time.
						</audio>
					</li>
					<li>
						<a href="#">Productos</a>
						<audio  style="display: none" id="beep-two3" controls preload="auto">
							<source src="../sonidos/click.mp3" controls></source>
							<source src="../sonidos/click.ogg" controls></source>
							Your browser isn't invited for super fun audio time.
						</audio>
					</li>
					<li class="marca">
						<a href="<?php echo $tienda; ?>">Tienda</a>
						<audio  style="display: none" id="beep-two4" controls preload="auto">
							<source src="../sonidos/click.mp3" controls></source>
							<source src="../sonidos/click.ogg" controls></source>
							Your browser isn't invited for super fun audio time.
						</audio>
					</li>
					
				</ul>
				
			</div>
				<div id="contenedorSesion" >
					<?php
						if( isset($_SESSION['usuario']) ){
							$estaPagina=$_SERVER['PHP_SELF'];
                                                        echo "Usuario: " . $_SESSION['usuario'];
                                                      //  echo '<a id="enlacePerfil" style="margin-left:1%;" class="_drawer-btn no-pjax" href="#">Mi perfil</a>';
							echo '<a id="enlaceSesion" style="margin-left:1%;" class="_drawer-btn no-pjax" href="../session_end.php">Salir</a>';
                                                        
                                                }else{
							echo " Invitado";
						}
                                                
					?>
				</div>
			
		</div>
                 <?php
                            $carrito = generarCarrito();
                            mostrarCarrito($carrito);
                        ?>
		<div id="contenido">
                            
                            <div id="titulo-shop">
                                <h3>Detalle del producto: <?php echo $detalle['descripcion']; ?></h3>
                            </div>
                        <div id="catalogo">
                       
                                <div id="product-page">
                                    <div id="product-img">
                                        <img src="../images/Productos/01-01.jpg" >
                                    </div>
                                    <div id="product-detail">
                                        <table id="table-detail-p">
                                            <tr>
                                                <td>Nombre: </td>
                                                <td><?php echo $detalle['descripcion']; ?></td>
                                            </tr>
                                            <tr>
                                                <td>Descripcion: </td>
                                                <td><?php echo $detalle['descripcion']; ?></td>
                                            </tr>
                                            <tr>
                                                <td>Precio: </td>
                                                <td><?php echo $detalle['precio']; ?> EUR</td>
                                            </tr>
                                            <tr>
                                                <td>Stock: </td>
                                                <td><?php if ($product->checkStock()) {echo "Hay stock";}else{echo "Sin Stock";}?></td>
                                            </tr>
                                            <tr>
                                                <td>A&ntilde;adir al carrito: </td>
                                                <td>
                                                    <form action=" <?php echo $_SERVER['PHP_SELF']. "?cat=$id_categoria&subcat=$id_subcategoria"; ?>" method="post">
                                                        <select name="cantidad">
                                                            <?php
                                                                for ($i = 1; $i <= $detalle['cantidad']; $i++)
                                                                {
                                                                    echo '<option value=" '.$i.' ">'.$i.'</option>';
                                                                }  
                                                            ?>
                                                        </select>
                                                        <input type="submit" value="Añadir">
                                                    </form>
                                                
                                                </td>
                                            </tr>
                                        </table>
                                
                                    </div>
				    <div id="pagination">
					   <h4><a class="pag" href="index.php" ><< Volver</a></h4>
				</div>
                                </div>
				
                    </div>
		</div>
                   <div id="footer">
				
				<!--  <div id="contenedorPie">
					<ul id="pie" class="efectoMenu">
						<li>Pie 1</li>
						<li>Pie 2</li>
						<li>Pie 3</li>
					</ul>
				</div>-->
				<div id="contenedorRedes">
					<ul id="redesSociales" class="efectoMenu">
						<li>Twitter</li>
						<li>Facebook</li>
						<li>Redimensionar</li>
					</ul>
				</div>
			</div>
	</div>
			
	</body>
</html>
